home *** CD-ROM | disk | FTP | other *** search
/ Take-Home Tutor en Espanol / TakeHomeTutor.iso / pc / En espanol / Take-Home Tutor 3 / template1.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2003-09-23  |  50.8 KB  |  1,849 lines

  1. function ext_XML_GET_TEXT()
  2. {
  3.    return this.firstChild.nodeType != 3 ? null : this.firstChild.nodeValue;
  4. }
  5. function ext_XML_SET_TEXT(text)
  6. {
  7.    this.firstChild.nodeValue = text;
  8. }
  9. function ActivityInfoItem()
  10. {
  11. }
  12. function ActivityInfo()
  13. {
  14. }
  15. function createIndexList(str, openTag, closeTag)
  16. {
  17.    var len = str.length;
  18.    var acntr = 0;
  19.    var otag = openTag;
  20.    var ctag = closeTag;
  21.    var abi = [];
  22.    var aei = [];
  23.    while(acntr < len)
  24.    {
  25.       acntr = str.indexOf(otag,acntr);
  26.       if(acntr == -1)
  27.       {
  28.          break;
  29.       }
  30.       abi.push(acntr);
  31.       acntr += otag.length;
  32.    }
  33.    acntr = 0;
  34.    while(acntr < len)
  35.    {
  36.       acntr = str.indexOf(ctag,acntr);
  37.       if(acntr == -1)
  38.       {
  39.          break;
  40.       }
  41.       aei.push(acntr);
  42.       acntr += ctag.length;
  43.    }
  44.    var rf = otag.length + ctag.length;
  45.    var i = 0;
  46.    while(i < abi.length)
  47.    {
  48.       if(i == 0)
  49.       {
  50.          aei[i] -= ctag.length - 1;
  51.       }
  52.       else
  53.       {
  54.          abi[i] -= rf * i;
  55.          aei[i] -= rf * i + otag.length;
  56.       }
  57.       i++;
  58.    }
  59.    return {startIndex:abi,endIndex:aei,length:abi.length};
  60. }
  61. function createInstructionField(cnt, name, text)
  62. {
  63.    text = simpleReplaceBlanks(text,"[:blank:]","[:/blank:]");
  64.    var hasBold = text.indexOf("[:bold:]") != -1;
  65.    if(cnt[name] == null)
  66.    {
  67.       var tmc = cnt.createEmptyMovieClip(name,1667);
  68.       tmc.createTextField("content",1,0,0,0,0);
  69.    }
  70.    else
  71.    {
  72.       var tmc = cnt[name];
  73.       tmc.swapDepths(1667);
  74.    }
  75.    tmc.isRemoveable = true;
  76.    tmc.isRemovable = true;
  77.    var tf = layoutInfo.instTextFormat;
  78.    tmc.content.border = false;
  79.    tmc.content.type = "dynamic";
  80.    if(hasBold)
  81.    {
  82.       tmc.content.text = text.replace("[:bold:]","").replace("[:/bold:]","");
  83.    }
  84.    else
  85.    {
  86.       tmc.content.text = text;
  87.    }
  88.    tmc.content._height = 400;
  89.    tmc.content.wordWrap = true;
  90.    tmc.content.color = layoutInfo.instTextColor;
  91.    tmc.content._width = 300;
  92.    tmc.content.autoSize = true;
  93.    tmc.content.selectable = false;
  94.    tmc.content.setTextFormat(tf);
  95.    tmc.content.embedFonts = true;
  96.    if(hasBold)
  97.    {
  98.       var idxLists = createIndexList(text,"[:bold:]","[:/bold:]");
  99.       var i = 0;
  100.       while(i < idxLists.length)
  101.       {
  102.          tmc.content.setTextFormat(idxLists.startIndex[i],idxLists.endIndex[i],layoutInfo.instTextFormatBold);
  103.          i++;
  104.       }
  105.    }
  106.    return tmc;
  107. }
  108. function changeInstructionField(insField, newText)
  109. {
  110.    createInstructionField(insField._parent,insField._name,newText);
  111. }
  112. function toggleLang()
  113. {
  114.    if(PMSI.instructionLanguage == "Spanish")
  115.    {
  116.       PMSI.instructionLanguage = "English";
  117.    }
  118.    else
  119.    {
  120.       PMSI.instructionLanguage = "Spanish";
  121.    }
  122.    var instText = ai["instructions" + PMSI.instructionLanguage].text;
  123.    if(instText != null)
  124.    {
  125.       var oldInstHeight = this.instructionField._height;
  126.       changeInstructionField(this.instructionField,instText);
  127.       var hdiff = this.instructionField._height - oldInstHeight;
  128.       reposition(hdiff);
  129.    }
  130.    pencilHelper.swapLangs();
  131. }
  132. function reposition(hdiff)
  133. {
  134.    var comp;
  135.    var dupList = {};
  136.    trace("******************************************");
  137.    for(var mcn in this)
  138.    {
  139.       comp = this[mcn];
  140.       if(comp.isMoveable && dupList[comp._name] == null)
  141.       {
  142.          trace("\t" + comp);
  143.          trace("\t\t" + comp.getDepth());
  144.          trace(hdiff);
  145.          comp._y += hdiff;
  146.          dupList[comp._name] = 1;
  147.       }
  148.    }
  149.    trace("******************************************");
  150. }
  151. function simpleReplaceBlanks(str, stag, etag)
  152. {
  153.    var cp = str.indexOf(stag);
  154.    var ei = 0;
  155.    while(cp != -1)
  156.    {
  157.       ei = str.indexOf(etag);
  158.       str = str.substring(0,cp) + "_____" + str.substring(ei + etag.length);
  159.       cp = str.indexOf(stag);
  160.    }
  161.    return str;
  162. }
  163. function loadActivity(fname)
  164. {
  165.    t = getTimer();
  166.    ai.load(fname);
  167. }
  168. function setActivityInfo(_ai)
  169. {
  170.    ai = _ai;
  171.    render();
  172.    return true;
  173. }
  174. function render()
  175. {
  176.    tabOrder = 4000;
  177.    table = new TableClass(this);
  178.    clearClip();
  179.    trace(this + ".render: called");
  180.    var tableY = 0;
  181.    if(ai.titleSpanish)
  182.    {
  183.       var title_mc = createTitleField(ai.titleSpanish);
  184.       title_mc._x = layoutInfo.box.x;
  185.       title_mc._y = layoutInfo.box.y;
  186.       tableY = title_mc._y + title_mc._height;
  187.    }
  188.    if(ai.instructionsEnglish || ai.instructionsSpanish)
  189.    {
  190.       if(ai.instructionsEnglish != null)
  191.       {
  192.          var instText = ai.instructionsEnglish.text;
  193.       }
  194.       else
  195.       {
  196.          var instText = ai.instructionsSpanish.text;
  197.       }
  198.       pinstText = ai["instructions" + PMSI.instructionLanguage].text;
  199.       instText = pinstText != null ? pinstText : instText;
  200.       var inst_mc = this.createInstructionField(this,"inst",instText);
  201.       inst_mc._x = layoutInfo.box.x;
  202.       inst_mc._y = title_mc == null ? layoutInfo.box.y : tableY;
  203.       tableY = inst_mc._y + inst_mc._height;
  204.       this.instructionField = inst_mc;
  205.    }
  206.    if(_parent.hasMediaFrame == false && _parent.actNumber_mc._height > inst_mc._height + title_mc._height)
  207.    {
  208.       tableY = _parent.actNumber_mc._y + _parent.actNumber_mc._height + 10;
  209.    }
  210.    if(master.hasMediaFrame)
  211.    {
  212.       rightSideBuffer = 280;
  213.    }
  214.    else
  215.    {
  216.       rightSideBuffer = 60;
  217.    }
  218.    trace("\t\tTABLEY!!: " + tableY);
  219.    var qlen = ai.questions.question.length;
  220.    var questionText;
  221.    var answerText1;
  222.    var answerText2;
  223.    var checkx;
  224.    var tc1;
  225.    var tc2;
  226.    var tc3;
  227.    var tc4;
  228.    var i = 0;
  229.    while(i < qlen)
  230.    {
  231.       tr = new TableRow();
  232.       var cnt = this;
  233.       var questionText = ai.questions.question[i].questionText.text;
  234.       var answerText1 = ai.questions.question[i].answerChoice[0].text;
  235.       var answerText2 = ai.questions.question[i].answerChoice[1].text;
  236.       var mc = createQuestionField(cnt,i,replaceBlanks(questionText.replace("\\n","\n"),Math.max(answerText1.length,answerText2.length)));
  237.       mc.isMoveable = true;
  238.       var amc1 = createAnswerField(cnt,i,1,ai.questions.question[i].answerChoice[0]);
  239.       var amc2 = createAnswerField(cnt,i,2,ai.questions.question[i].answerChoice[1]);
  240.       amc1.partner = amc2;
  241.       amc2.partner = amc1;
  242.       amc1.isMoveable = true;
  243.       amc2.isMoveable = true;
  244.       amc1.tabIndex = tabOrder++;
  245.       amc2.tabIndex = tabOrder++;
  246.       amc1.isCorrect = amc1.content.text == ai.questions.question[i].correctAnswer.text;
  247.       amc2.isCorrect = amc2.content.text == ai.questions.question[i].correctAnswer.text;
  248.       checkx = this.attachMovie("check","checkx" + i,3321 + i);
  249.       checkx.isMoveable = true;
  250.       amc1.checkx = checkx;
  251.       amc2.checkx = checkx;
  252.       tc1 = new TableCell(mc);
  253.       tc1.setHAlign("right");
  254.       tc2 = new TableCell(amc1);
  255.       tc3 = new TableCell(amc2);
  256.       tc4 = new TableCell(checkx);
  257.       tr.addCell(tc1);
  258.       tr.addCell(tc2);
  259.       tr.addCell(tc3);
  260.       tr.addCell(tc4);
  261.       table.addRow(tr);
  262.       i++;
  263.    }
  264.    trace("\t\tTABLEY!!: " + tableY);
  265.    table.setPosition({x:layoutInfo.box.x,y:tableY + 20});
  266.    table.setCellSpacing(10);
  267.    table.init();
  268.    var twid = layoutInfo.MAX_WIDTH - rightSideBuffer;
  269.    trace("SETTING TABLE WIDTH: " + twid);
  270.    if(twid < table.width)
  271.    {
  272.       table.setWidth(twid);
  273.    }
  274.    master.onRender();
  275. }
  276. function answerOnRollOver()
  277. {
  278.    this.rollOverColor = new Color(this);
  279.    this.rollOverColor.setRGB(layoutInfo.answerRollOverColor);
  280. }
  281. function answerOnRollOut()
  282. {
  283.    this.rollOutColor = new Color(this);
  284.    if(this.isIncorrect)
  285.    {
  286.       this.rollOutColor.setRGB(layoutInfo.answerIncorrectColor);
  287.    }
  288.    else if(!this.isSelected)
  289.    {
  290.       this.clear();
  291.       this.rollOutColor.setRGB(layoutInfo.answerRollOutColor);
  292.    }
  293.    else
  294.    {
  295.       this.rollOutColor.setRGB(layoutInfo.answerSelectColor);
  296.    }
  297. }
  298. function setColorIncorrect(oIns)
  299. {
  300.    oIns.isIncorrect = true;
  301.    oIns.incorrectColor = new Color(oIns);
  302.    oIns.incorrectColor.setRGB(layoutInfo.answerIncorrectColor);
  303. }
  304. function answerOnRelease()
  305. {
  306.    this.isIncorrect = false;
  307.    this.isSelected = !this.isSelected;
  308.    if(this.isSelected && layoutInfo.drawSelectionCircle)
  309.    {
  310.       this.lineStyle(layoutInfo.selectionBorderThickness,0,60);
  311.       if(layoutInfo.doAnswerFill)
  312.       {
  313.          this.beginFill(16777215,10);
  314.       }
  315.       this.drawRect(localToGlobal(this._x),localToGlobal(this._y),this._width,this._height,layoutInfo.selectionRadius);
  316.       if(layoutInfo.doAnswerFill)
  317.       {
  318.          this.endFill();
  319.       }
  320.    }
  321.    else
  322.    {
  323.       this.clear();
  324.    }
  325.    this.partner.isIncorrect = false;
  326.    this.partner.isSelected = false;
  327.    this.partner.clear();
  328.    this.partner.onRollOut();
  329.    this.answerOnReleaseColor = new Color(this);
  330.    this.answerOnReleaseColor.setRGB(layoutInfo.answerSelectColor);
  331. }
  332. function createQuestionField(cnt, id, text)
  333. {
  334.    var mc = cnt.createEmptyMovieClip("question" + id,4565 + id);
  335.    mc.createTextField("content",1,0,0,0,0);
  336.    var tf = layoutInfo.qTextFormat;
  337.    mc.content.embedFonts = true;
  338.    mc.content.border = TXT_DEBUG_SHOW_BORDERS;
  339.    mc.content.type = "dynamic";
  340.    mc.content.text = text;
  341.    mc.content.autoSize = true;
  342.    mc.content.setTextFormat(tf);
  343.    mc.content.selectable = false;
  344.    return mc;
  345. }
  346. function createAnswerField(cnt, id, subid, text)
  347. {
  348.    var amc1 = cnt.createEmptyMovieClip("answer" + subid + "_" + id,parseInt("77" + subid + "" + id));
  349.    trace("\t" + parseInt("47" + id + "" + subid));
  350.    amc1.createTextField("content",1,0,0,0,0);
  351.    var tf2 = layoutInfo.answerTextFormat1;
  352.    amc1.content.embedFonts = true;
  353.    amc1.content.border = TXT_DEBUG_SHOW_BORDERS;
  354.    amc1.content.type = "dynamic";
  355.    amc1.content.text = text;
  356.    amc1.content.autoSize = true;
  357.    amc1.content.selectable = false;
  358.    amc1.content.setTextFormat(tf2);
  359.    amc1.onRollOver = answerOnRollOver;
  360.    amc1.onRollOut = answerOnRollOut;
  361.    amc1.onReleaseOutside = answerOnRollOut;
  362.    amc1.onRelease = answerOnRelease;
  363.    return amc1;
  364. }
  365. function createAnswerSpacer(cnt, id)
  366. {
  367.    var amcSpacer = cnt.createEmptyMovieClip("answerSpacer_" + id,4867 + id);
  368.    amcSpacer.createTextField("content",1,0,0,0,0);
  369.    var tf2 = layoutInfo.answerTextFormat1;
  370.    amcSpacer.content.embedFonts = true;
  371.    amcSpacer.content.border = TXT_DEBUG_SHOW_BORDERS;
  372.    amcSpacer.content.type = "dynamic";
  373.    amcSpacer.content.text = "  ";
  374.    amcSpacer.content.autoSize = true;
  375.    amcSpacer.content.setTextFormat(tf2);
  376.    amcSpacer.content.selectable = false;
  377.    return amcSpacer;
  378. }
  379. function checkAnswers()
  380. {
  381.    var qlen = ai.questions.question.length;
  382.    var correct = 0;
  383.    var par = this;
  384.    var a1;
  385.    var a2;
  386.    var i = 0;
  387.    while(i < qlen)
  388.    {
  389.       a1 = par["answer1_" + i];
  390.       a2 = par["answer2_" + i];
  391.       if(a1.isSelected && a1.isCorrect || a2.isSelected && a2.isCorrect)
  392.       {
  393.          correct++;
  394.          a1.checkx.gotoAndStop("correct");
  395.          a2.checkx.gotoAndStop("correct");
  396.       }
  397.       if(a1.isSelected && !a1.isCorrect)
  398.       {
  399.          a1.checkx.gotoAndStop("incorrect");
  400.       }
  401.       if(a2.isSelected && !a2.isCorrect)
  402.       {
  403.          a1.checkx.gotoAndStop("incorrect");
  404.       }
  405.       if(!a1.isSelected && !a2.isSelected)
  406.       {
  407.          a1.checkx.gotoAndStop("incorrect");
  408.          a2.checkx.gotoAndStop("incorrect");
  409.       }
  410.       i++;
  411.    }
  412.    master.setFeedback(correct,qlen);
  413. }
  414. function createTitleField(txt)
  415. {
  416.    var mc = this.createEmptyMovieClip("title",2223);
  417.    mc.createTextField("content",1,0,0,0,0);
  418.    var tf = layoutInfo.titleTextFormat;
  419.    mc.content.embedFonts = true;
  420.    mc.content.border = false;
  421.    mc.content.type = "dynamic";
  422.    mc.content.text = txt;
  423.    mc.content.setTextFormat(tf);
  424.    mc.content.wordWrap = true;
  425.    mc.content.color = layoutInfo.instTextColor;
  426.    mc.content._width = 300;
  427.    mc.content.autoSize = true;
  428.    mc.content.selectable = false;
  429.    return mc;
  430. }
  431. function highlightIncorrect(text)
  432. {
  433. }
  434. function clearClip()
  435. {
  436.    layoutInfo.qMaxWidthPos = 0;
  437.    layoutInfo.qMaxWidth = 0;
  438.    layoutInfo.a1MaxWidth = 0;
  439.    layoutInfo.a2MaxWidth = 0;
  440.    for(var mc in this)
  441.    {
  442.       if(this[mc] != _parent && this[mc] != this)
  443.       {
  444.          this[mc].clear();
  445.          this[mc].removeMovieClip();
  446.       }
  447.    }
  448. }
  449. function drawDebugBox()
  450. {
  451.    this.lineStyle(1,16711680,100);
  452.    this.drawRect(layoutInfo.box.x,layoutInfo.box.y,layoutInfo.MAX_WIDTH,layoutInfo.MAX_HEIGHT);
  453. }
  454. function replaceBlanks(s_str, maxlen)
  455. {
  456.    trace("MAXLEN: " + maxlen);
  457.    var str = s_str.toString();
  458.    return replaceBlanksR(str,maxlen);
  459. }
  460. function replaceBlanksR(s_str, maxlen)
  461. {
  462.    trace(s_str);
  463.    var si = s_str.indexOf(TAGS.BLANK_OPEN);
  464.    if(si == -1)
  465.    {
  466.       return s_str;
  467.    }
  468.    var ei = s_str.indexOf(TAGS.BLANK_CLOSE) + TAGS.BLANK_CLOSE.length;
  469.    s_str = s_str.slice(0,si) + makeStringFromChar("_",maxlen) + s_str.slice(ei,s_str.length);
  470.    return replaceBlanks(s_str,maxlen);
  471. }
  472. function makeStringFromChar(char, length)
  473. {
  474.    var str = "";
  475.    var i = 0;
  476.    while(i < length)
  477.    {
  478.       str += char;
  479.       i++;
  480.    }
  481.    return str;
  482. }
  483. if(_global.PMSI == null)
  484. {
  485.    _global.PMSI = {};
  486.    PMSI.VENDOR_NAME = "Purple Monkey Studios, Inc.";
  487.    PMSI.DefList = {};
  488. }
  489. String.prototype.trim = function()
  490. {
  491.    return this.rtrim().ltrim();
  492. };
  493. String.prototype.rtrim = function()
  494. {
  495.    var i = this.length - 1;
  496.    while(i >= 0 && this.charCodeAt(i) <= 32)
  497.    {
  498.       i--;
  499.    }
  500.    return this.substring(0,i + 1);
  501. };
  502. String.prototype.ltrim = function()
  503. {
  504.    var i = 0;
  505.    while(i < this.length && this.charCodeAt(i) <= 32)
  506.    {
  507.       i++;
  508.    }
  509.    return this.substring(i);
  510. };
  511. String.prototype.isWhiteSpace = function()
  512. {
  513.    var i = 0;
  514.    while(i < this.length)
  515.    {
  516.       if(this.charCodeAt(i) > 32)
  517.       {
  518.          return false;
  519.       }
  520.       i++;
  521.    }
  522.    return true;
  523. };
  524. String.prototype.toCharArray = function()
  525. {
  526.    return this.split("");
  527. };
  528. Array.prototype.charArrayToString = function()
  529. {
  530.    return this.join("");
  531. };
  532. String.prototype.reverse = function()
  533. {
  534.    return this.split("").reverse().join("");
  535. };
  536. String.prototype.multiSplit = function()
  537. {
  538.    var master;
  539.    var dummy;
  540.    var args;
  541.    master = this.split(arguments[0]);
  542.    var i = 1;
  543.    while(i < arguments.length)
  544.    {
  545.       var j = 0;
  546.       while(j < master.length)
  547.       {
  548.          dummy = master[j].split(arguments[i]);
  549.          if(dummy.length > 1)
  550.          {
  551.             args = [j,1];
  552.             args = args.concat(dummy);
  553.             master.splice.apply(master,args);
  554.          }
  555.          j++;
  556.       }
  557.       i++;
  558.    }
  559.    return master;
  560. };
  561. String.prototype.replace = function(srch, repl)
  562. {
  563.    return this.split(srch).join(repl);
  564. };
  565. XML.prototype.ELEMENT_NODE = 1;
  566. XML.prototype.TEXT_NODE = 3;
  567. XML.prototype._inorderItr = function(node, fnPtr)
  568. {
  569.    var stack = new Array();
  570.    var node = node;
  571.    while(true)
  572.    {
  573.       if(node)
  574.       {
  575.          stack.push(node);
  576.          node = node.firstChild;
  577.       }
  578.       else
  579.       {
  580.          node = stack.pop();
  581.          if(!node)
  582.          {
  583.             break;
  584.          }
  585.          fnPtr(node);
  586.          node = node.nextSibling;
  587.       }
  588.    }
  589.    delete stack;
  590. };
  591. XMLNode.prototype._inorderItr = XML.prototype._inorderItr;
  592. XML.prototype._inorderRec = function(node, fnPtr)
  593. {
  594.    function helperR(node_xml)
  595.    {
  596.       if(node_xml == null)
  597.       {
  598.          return undefined;
  599.       }
  600.       this.fnPtr(node_xml);
  601.       helperR(node_xml.firstChild);
  602.       helperR(node_xml.nextSibling);
  603.    }
  604.    var outer = this;
  605.    helperR(node);
  606. };
  607. XMLNode.prototype._inorderRec = XML.prototype._inorderRec;
  608. XMLNode.prototype.addProperty("text",this.ext_XML_GET_TEXT,this.ext_XML_SET_TEXT);
  609. XML.prototype.addProperty("text",this.ext_XML_GET_TEXT,this.ext_XML_SET_TEXT);
  610. XML.prototype.getElementsByTagName = function(tagName)
  611. {
  612.    function processNode(node)
  613.    {
  614.       if(node.nodeName != null && node.nodeName == tagName)
  615.       {
  616.          nodelist.push(node);
  617.       }
  618.    }
  619.    var nodelist = new Array();
  620.    this._inorderItr(this,processNode);
  621.    return nodelist;
  622. };
  623. XMLNode.prototype.getElementsByTagName = XML.prototype.getElementsByTagName;
  624. XML.prototype.getElementsByTagNames = function()
  625. {
  626.    function processNode(node)
  627.    {
  628.       var i = 0;
  629.       while(i < args.length)
  630.       {
  631.          if(node.nodeName != null && node.nodeName == args[i])
  632.          {
  633.             trace("Found: " + args[i]);
  634.             if(nodelists[i] == undefined)
  635.             {
  636.                nodelists[i] = new Array();
  637.             }
  638.             nodelists[i].push(node);
  639.             break;
  640.          }
  641.          i++;
  642.       }
  643.    }
  644.    var args = arguments;
  645.    var nodelists = new Array(arguments.length);
  646.    this._inorderItr(this,processNode);
  647.    return nodelists;
  648. };
  649. XMLNode.prototype.getElementsByTagNames = XML.prototype.getElementsByTagNames;
  650. XML.prototype.getValueAtTagName = function(tagName)
  651. {
  652.    function processNode(node)
  653.    {
  654.       if(node.nodeName != null && node.nodeName == tagName)
  655.       {
  656.          nodelist.push(node);
  657.       }
  658.    }
  659.    var nodelist = new Array();
  660.    var textValue = null;
  661.    this._inorderItr(this,processNode);
  662.    if(nodeList.length >= 1)
  663.    {
  664.       textValue = nodeList[0].text;
  665.    }
  666.    return textValue;
  667. };
  668. XMLNode.prototype.getValueAtTagName = XML.prototype.getValueAtTagName;
  669. XML.prototype.getAttribute = function(name)
  670. {
  671.    return this.attributes[name];
  672. };
  673. XMLNode.prototype.getAttribute = XML.prototype.getAttribute;
  674. XML.prototype.setAttribute = function(name, value)
  675. {
  676.    this.attributes[name] = value;
  677. };
  678. XMLNode.prototype.setAttribute = XML.prototype.setAttribute;
  679. XML.prototype.hasAttribute = function(name)
  680. {
  681.    var attrs = this.attributes;
  682.    for(var mc in attrs)
  683.    {
  684.       if(name == mc)
  685.       {
  686.          return true;
  687.       }
  688.    }
  689.    return false;
  690. };
  691. XMLNode.prototype.hasAttribute = XML.prototype.hasAttribute;
  692. XML.prototype.removeAttribute = function(name)
  693. {
  694.    var attr = this.attributes[name];
  695.    delete this.attributes[name];
  696.    return attr;
  697. };
  698. XMLNode.prototype.setAttribute = XML.prototype.setAttribute;
  699. XMLNode.prototype.getOwnerDocument = function()
  700. {
  701.    var odc = this;
  702.    var lastNode = this;
  703.    while(odc)
  704.    {
  705.       lastNode = odc;
  706.       odc = odc.parentNode;
  707.    }
  708.    return !(lastNode instanceof XML) ? null : lastNode;
  709. };
  710. XML.prototype.normalize = function()
  711. {
  712.    function process(node)
  713.    {
  714.       nodeList.push(node);
  715.    }
  716.    var outer = this;
  717.    var nodeList = new Array();
  718.    this._inorderItr(this,process);
  719.    var i = 0;
  720.    while(i < nodeList.length)
  721.    {
  722.       var node = nodeList[i];
  723.       if(node.nodeType == XML.prototype.TEXT_NODE && node.nodeValue.isWhiteSpace())
  724.       {
  725.          trace("removing node");
  726.          node.removeNode();
  727.       }
  728.       else if(node.nodeType == XML.prototype.TEXT_NODE)
  729.       {
  730.          node.nodeValue = node.nodeValue.trim();
  731.       }
  732.       i++;
  733.    }
  734.    delete nodeList;
  735. };
  736. XMLNode.prototype.normalize = XML.prototype.normalize;
  737. XMLNode.prototype.getDepth = function()
  738. {
  739.    var i = 0;
  740.    var node = this;
  741.    while(node)
  742.    {
  743.       node = node.parentNode;
  744.       i++;
  745.    }
  746.    return i;
  747. };
  748. XML.prototype.getElementsWithAttribute = function(name, value)
  749. {
  750.    function processNode(node)
  751.    {
  752.       if(value == null)
  753.       {
  754.          for(var mcz in node.attributes)
  755.          {
  756.             if(mcz == name)
  757.             {
  758.                nodeList.push(node);
  759.                break;
  760.             }
  761.          }
  762.       }
  763.       else if(node.attributes[name] == value)
  764.       {
  765.          nodeList.push(node);
  766.       }
  767.    }
  768.    if(name == null)
  769.    {
  770.       return undefined;
  771.    }
  772.    var nodeList = new Array();
  773.    this._inorderItr(this,processNode);
  774.    return nodeList;
  775. };
  776. XMLNode.prototype.getElementsWithAttribute = XML.prototype.getElementsWithAttribute;
  777. XMLNode.prototype.getPath = function(path)
  778. {
  779.    function process(node)
  780.    {
  781.       trace(node.nodeName);
  782.       if(node.nodeName != null && node.nodeName == currentPart && i < pathParts.length)
  783.       {
  784.          trace("Found: " + currentPart);
  785.          partTable[i] = node.parentNode.getElementsByTagName(currentPart);
  786.          currentPart = pathParts[++i];
  787.       }
  788.    }
  789.    var i = 0;
  790.    var pathParts = path.split("/");
  791.    var currentPart = pathParts[i];
  792.    var partTable = new Array();
  793.    this._inorderItr(this,process);
  794.    return partTable[partTable.length - 1];
  795. };
  796. XML.prototype.getPath = XMLNode.prototype.getPath;
  797. MovieClip.prototype.isLoading = function()
  798. {
  799.    return this.getBytesLoaded() > 4 && this.getBytesTotal() > this.getBytesLoaded();
  800. };
  801. MovieClip.prototype.getPercentLoaded = function()
  802. {
  803.    return Math.round(this.getBytesLoaded() / this.getBytesTotal() * 100);
  804. };
  805. MovieClip.prototype.isLoaded = function()
  806. {
  807.    return !this.isLoading();
  808. };
  809. MovieClip.prototype._sol = function(f)
  810. {
  811.    if(MovieClip.prototype.__onLoadHandler__ == undefined)
  812.    {
  813.       MovieClip.prototype.__onLoadHandler__ = {};
  814.    }
  815.    MovieClip.prototype.__onLoadHandler__[this] = f;
  816. };
  817. MovieClip.prototype._gol = function()
  818. {
  819.    return MovieClip.prototype.__onLoadHandler__[this];
  820. };
  821. MovieClip.prototype.addProperty("onLoad",MovieClip.prototype._gol,MovieClip.prototype._sol);
  822. MovieClip.prototype._sod = function(f)
  823. {
  824.    if(MovieClip.prototype.__onDataHandler__ == undefined)
  825.    {
  826.       MovieClip.prototype.__onDataHandler__ = {};
  827.    }
  828.    MovieClip.prototype.__onDataHandler__[this] = f;
  829. };
  830. MovieClip.prototype._god = function()
  831. {
  832.    return MovieClip.prototype.__onDataHandler__[this];
  833. };
  834. MovieClip.prototype.addProperty("onData",MovieClip.prototype._god,MovieClip.prototype._sod);
  835. MovieClip.prototype.load = MovieClip.prototype.loadMovie;
  836. MovieClip.prototype.drawOval = function(x, y, radius, yRadius)
  837. {
  838.    if(arguments.length < 3)
  839.    {
  840.       return undefined;
  841.    }
  842.    var theta;
  843.    var xrCtrl;
  844.    var yrCtrl;
  845.    var angle;
  846.    var angleMid;
  847.    var px;
  848.    var py;
  849.    var cx;
  850.    var cy;
  851.    if(yRadius == undefined)
  852.    {
  853.       yRadius = radius;
  854.    }
  855.    theta = 0.7853981633974483;
  856.    xrCtrl = radius / Math.cos(theta / 2);
  857.    yrCtrl = yRadius / Math.cos(theta / 2);
  858.    angle = 0;
  859.    this.moveTo(x + radius,y);
  860.    var i = 0;
  861.    while(i < 8)
  862.    {
  863.       angle += theta;
  864.       angleMid = angle - theta / 2;
  865.       cx = x + Math.cos(angleMid) * xrCtrl;
  866.       cy = y + Math.sin(angleMid) * yrCtrl;
  867.       px = x + Math.cos(angle) * radius;
  868.       py = y + Math.sin(angle) * yRadius;
  869.       this.curveTo(cx,cy,px,py);
  870.       i++;
  871.    }
  872. };
  873. MovieClip.prototype.drawCircle = function(x, y, r)
  874. {
  875.    this.drawOval(x,y,r);
  876. };
  877. MovieClip.prototype.drawSquare = function(x, y, w)
  878. {
  879.    this.drawRect(x,y,w,w);
  880. };
  881. MovieClip.prototype.drawEgg = function(x, y, r)
  882. {
  883.    var rx = r / 1.618;
  884.    var ry = r;
  885.    var ry1 = 2 * ry * 0.618;
  886.    var ry2 = 2 * ry * 0.382;
  887.    this.moveTo(x + rx,y);
  888.    this.curveTo(rx + x,-0.4142 * ry1 + y,0.7071 * rx + x,-0.7071 * ry1 + y);
  889.    this.curveTo(0.4142 * rx + x,- ry1 + y,x,- ry1 + y);
  890.    this.curveTo(-0.4142 * rx + x,- ry1 + y,-0.7071 * rx + x,-0.7071 * ry1 + y);
  891.    this.curveTo(- rx + x,-0.4142 * ry1 + y,- rx + x,y);
  892.    this.curveTo(- rx + x,0.4142 * ry2 + y,-0.7071 * rx + x,0.7071 * ry2 + y);
  893.    this.curveTo(-0.4142 * rx + x,ry2 + y,x,ry2 + y);
  894.    this.curveTo(0.4142 * rx + x,ry2 + y,0.7071 * rx + x,0.7071 * ry2 + y);
  895.    this.curveTo(rx + x,0.4142 * ry2 + y,rx + x,y);
  896. };
  897. MovieClip.prototype.drawRect = function(x, y, w, h, cornerRadius)
  898. {
  899.    if(arguments.length < 4)
  900.    {
  901.       return undefined;
  902.    }
  903.    if(cornerRadius > 0)
  904.    {
  905.       var theta;
  906.       var angle;
  907.       var cx;
  908.       var cy;
  909.       var px;
  910.       var py;
  911.       if(cornerRadius > Math.min(w,h) / 2)
  912.       {
  913.          cornerRadius = Math.min(w,h) / 2;
  914.       }
  915.       theta = 0.7853981633974483;
  916.       this.moveTo(x + cornerRadius,y);
  917.       this.lineTo(x + w - cornerRadius,y);
  918.       angle = -1.5707963267948966;
  919.       cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  920.       cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  921.       px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
  922.       py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
  923.       this.curveTo(cx,cy,px,py);
  924.       angle += theta;
  925.       cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  926.       cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  927.       px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
  928.       py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
  929.       this.curveTo(cx,cy,px,py);
  930.       this.lineTo(x + w,y + h - cornerRadius);
  931.       angle += theta;
  932.       cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  933.       cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  934.       px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
  935.       py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
  936.       this.curveTo(cx,cy,px,py);
  937.       angle += theta;
  938.       cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  939.       cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  940.       px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
  941.       py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
  942.       this.curveTo(cx,cy,px,py);
  943.       this.lineTo(x + cornerRadius,y + h);
  944.       angle += theta;
  945.       cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  946.       cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  947.       px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
  948.       py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
  949.       this.curveTo(cx,cy,px,py);
  950.       angle += theta;
  951.       cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  952.       cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  953.       px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
  954.       py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
  955.       this.curveTo(cx,cy,px,py);
  956.       this.lineTo(x,y + cornerRadius);
  957.       angle += theta;
  958.       cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  959.       cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  960.       px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
  961.       py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
  962.       this.curveTo(cx,cy,px,py);
  963.       angle += theta;
  964.       cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  965.       cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  966.       px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
  967.       py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
  968.       this.curveTo(cx,cy,px,py);
  969.    }
  970.    else
  971.    {
  972.       this.moveTo(x,y);
  973.       this.lineTo(x + w,y);
  974.       this.lineTo(x + w,y + h);
  975.       this.lineTo(x,y + h);
  976.       this.lineTo(x,y);
  977.    }
  978. };
  979. MovieClip.prototype.getCenterPoint = function()
  980. {
  981.    return {x:this._width / 2,y:this._height / 2};
  982. };
  983. MovieClip.prototype.drawDebugBorderD = function()
  984. {
  985.    this.lineStyle(1,0,25);
  986.    var x;
  987.    var y = 0;
  988.    var w = this._width;
  989.    var h = this._height;
  990.    this.moveTo(x,y);
  991.    this.lineTo(x + w,y);
  992.    this.lineTo(x + w,y + h);
  993.    this.lineTo(x,y + h);
  994.    this.lineTo(x,y);
  995. };
  996. MovieClip.prototype.drawUnderline = function(len)
  997. {
  998.    len = len != null ? len : this._width;
  999.    this.moveTo(0,this._height);
  1000.    this.lineTo(len,this._height);
  1001. };
  1002. if(PMSI.DepthManager == undefined)
  1003. {
  1004.    PMSI.DepthManager = {};
  1005.    PMSI.DepthManager._$depth = 0;
  1006.    PMSI.DepthManager.getNextDepth = function()
  1007.    {
  1008.       var next_depth = ++this._$depth;
  1009.       while(this._$depthsClaimed["dc" + next_depth])
  1010.       {
  1011.          next_depth = ++this._$depth;
  1012.       }
  1013.       return next_depth;
  1014.    };
  1015.    PMSI.DepthManager.reserveDepth = function(d)
  1016.    {
  1017.       if(this._$depthsClaimed == null)
  1018.       {
  1019.          this._$depthsClaimed = {};
  1020.       }
  1021.       if(d == null)
  1022.       {
  1023.          var d = ++this._$depth;
  1024.       }
  1025.       while(this._$depthsClaimed["dc" + d])
  1026.       {
  1027.          d++;
  1028.       }
  1029.       this._$depthsClaimed["dc" + d] = d;
  1030.       return d;
  1031.    };
  1032. }
  1033. ActivityInfoItem.prototype.toString = function()
  1034. {
  1035.    return this.text;
  1036. };
  1037. ActivityInfo.prototype.getIdString = function(separator)
  1038. {
  1039.    var sep = separator != null ? separator : ".";
  1040.    var idStr = "C" + this.activity.course + sep;
  1041.    idStr += "U" + this.activity.unit + sep;
  1042.    idStr += "S" + this.activity.section + sep;
  1043.    idStr += this.activity.topic + sep;
  1044.    if(this.activity.topicSet)
  1045.    {
  1046.       idStr += this.activity.topicSet + sep;
  1047.    }
  1048.    idStr += this.activity.difficultyLevel + this.activity.number.text;
  1049.    return idStr;
  1050. };
  1051. ActivityInfo.prototype.getId = ActivityInfo.prototype.getIdString;
  1052. ActivityInfo.prototype.getType = function()
  1053. {
  1054.    return this.activity.type;
  1055. };
  1056. ActivityInfo.prototype.hasAudio = function()
  1057. {
  1058.    return this.activity.audioFile == null ? false : true;
  1059. };
  1060. ActivityInfo.prototype.hasVideo = function()
  1061. {
  1062.    return this.activity.videoFile == null ? false : true;
  1063. };
  1064. ActivityInfo.prototype.hasPicture = function()
  1065. {
  1066.    return this.activity.artFile == null ? false : true;
  1067. };
  1068. ActivityInfo.prototype.setResolve = function()
  1069. {
  1070.    this.__resolve = ActivityInfo.prototype._myResolve;
  1071. };
  1072. ActivityInfo.prototype._myResolve = function(name)
  1073. {
  1074.    return this.activity[name];
  1075. };
  1076. ActivityInfo.prototype.getBytesLoaded = function()
  1077. {
  1078.    return this.xmlSource.getBytesLoaded();
  1079. };
  1080. ActivityInfo.prototype.getBytesTotal = function()
  1081. {
  1082.    return this.xmlSource.getBytesTotal();
  1083. };
  1084. ActivityInfo.prototype.load = function(url)
  1085. {
  1086.    this._reset();
  1087.    this.xmlSource = new XML();
  1088.    var x = this.xmlSource;
  1089.    x.parent = this;
  1090.    x.ignoreWhite = true;
  1091.    x.createAttributeArray = function(attrs)
  1092.    {
  1093.    };
  1094.    x.onLoad = function(success)
  1095.    {
  1096.       function helperR(node_xml, obj)
  1097.       {
  1098.          if(node_xml == null)
  1099.          {
  1100.             return undefined;
  1101.          }
  1102.          var nName = node_xml.nodeName;
  1103.          if(nName == "number")
  1104.          {
  1105.             nName = "activityNumber";
  1106.          }
  1107.          if(nName != null && obj[nName] == null)
  1108.          {
  1109.             var newObj = new ActivityInfoItem();
  1110.             newObj.text = node_xml.text.trim();
  1111.             if(node_xml.attributes)
  1112.             {
  1113.                trace("creating new attributes array");
  1114.                newObj.attributes = {};
  1115.                for(var oname in node_xml.attributes)
  1116.                {
  1117.                   newObj.attributes[oname] = node_xml.attributes[oname];
  1118.                }
  1119.             }
  1120.             obj[nName] = newObj;
  1121.          }
  1122.          else if(!(obj[nName] instanceof Array) && obj[nName] != null)
  1123.          {
  1124.             var temp = obj[nName];
  1125.             obj[nName] = [];
  1126.             obj[nName].push(temp);
  1127.          }
  1128.          var childObject = obj[nName];
  1129.          if(childObject instanceof Array)
  1130.          {
  1131.             var newObj = new ActivityInfoItem();
  1132.             newObj.text = node_xml.text.trim();
  1133.             if(node_xml.attributes)
  1134.             {
  1135.                trace("creating new attributes array");
  1136.                newObj.attributes = {};
  1137.                for(var oname in node_xml.attributes)
  1138.                {
  1139.                   newObj.attributes[oname] = node_xml.attributes[oname];
  1140.                }
  1141.             }
  1142.             childObject = newObj;
  1143.             obj[nName].push(childObject);
  1144.          }
  1145.          helperR(node_xml.firstChild,childObject);
  1146.          helperR(node_xml.nextSibling,obj);
  1147.       }
  1148.       if(success)
  1149.       {
  1150.          helperR(this.firstChild,this.parent);
  1151.          this.parent.setResolve();
  1152.       }
  1153.       this.parent.onLoad(success);
  1154.    };
  1155.    x.load(url);
  1156. };
  1157. ActivityInfo.prototype._reset = function()
  1158. {
  1159.    delete this.xmlSource;
  1160.    delete this.__resolve;
  1161.    delete this.activity;
  1162. };
  1163. TableClass = function(parent)
  1164. {
  1165.    this.parent = parent;
  1166.    this.reduceTextFields = true;
  1167.    this.rows = [];
  1168.    this.maxCellDims = {width:0,height:0};
  1169.    this.cellPadding = 4;
  1170.    this.cellSpacing = 4;
  1171.    this.colWidthMaxs = [];
  1172.    this.colPercentTable = [];
  1173.    this.borderSize = 1;
  1174.    this.width = 0;
  1175.    this.height = 0;
  1176.    this.oldWidth = this.width;
  1177.    this.oldHeight = this.oldHeight;
  1178.    this.originalWidth = 0;
  1179.    this.x = 0;
  1180.    this.y = 0;
  1181.    this.alteredColumns = {};
  1182.    var dep = PMSI.DepthManager.getNextDepth();
  1183.    this.borderClip = parent.createEmptyMovieClip("TableClassBorder" + dep,dep);
  1184. };
  1185. TableClass.prototype.setPosition = function(position)
  1186. {
  1187.    this.x = position.x;
  1188.    this.y = position.y;
  1189. };
  1190. TableClass.prototype.getPosition = function()
  1191. {
  1192.    return {x:this.x,y:this.y};
  1193. };
  1194. TableClass.prototype.setBorder = function(bsize)
  1195. {
  1196.    this.borderSize = bsize;
  1197. };
  1198. TableClass.prototype.addRow = function(newRow)
  1199. {
  1200.    this.rows.push(newRow);
  1201.    var cells = newRow.cells;
  1202.    var cellCount = cells.length;
  1203.    var cwms = this.colWidthMaxs;
  1204.    var cw = null;
  1205.    var newWidth = 0;
  1206.    var con = null;
  1207.    var c = 0;
  1208.    while(c < cellCount)
  1209.    {
  1210.       con = cells[c].getContent();
  1211.       cw = con == null ? cells[c].width : con._width;
  1212.       if(cwms[c] == null)
  1213.       {
  1214.          cwms[c] = cw;
  1215.       }
  1216.       else
  1217.       {
  1218.          cwms[c] = cw <= cwms[c] ? cwms[c] : cw;
  1219.       }
  1220.       newWidth += cwms[c];
  1221.       c++;
  1222.    }
  1223.    this.originalWidth = newWidth;
  1224.    this.width = newWidth;
  1225.    trace("NEW WIDTH: " + this.width);
  1226. };
  1227. TableClass.prototype.addRowSpacer = function(height, width, numCols)
  1228. {
  1229.    if(numCols == null && this.rows.length == 0)
  1230.    {
  1231.       return undefined;
  1232.    }
  1233.    numCols = this.rows[0].cells.length;
  1234.    var spacerRow = new TableRow();
  1235.    var spacerCell = null;
  1236.    var i = 0;
  1237.    while(i < numCols)
  1238.    {
  1239.       spacerCell = new TableCell();
  1240.       spacerCell.height = height;
  1241.       spacerCell.width = width;
  1242.       spacerRow.addCell(spacerCell);
  1243.       i++;
  1244.    }
  1245.    this.addRow(spacerRow);
  1246. };
  1247. TableClass.prototype.setCellPadding = function(cellPadding)
  1248. {
  1249.    this.cellPadding = cellPadding;
  1250.    this.redraw();
  1251. };
  1252. TableClass.prototype.setCellSpacing = function(cellSpacing)
  1253. {
  1254.    this.cellSpacing = cellSpacing;
  1255.    this.redraw();
  1256. };
  1257. TableClass.prototype.setWidth = function(width)
  1258. {
  1259.    this.oldWidth = this.width;
  1260.    this.width = width;
  1261.    this._recalcDimensions(width);
  1262.    this.redraw();
  1263.    this.redraw();
  1264. };
  1265. TableClass.prototype.setHeight = function(height)
  1266. {
  1267.    this.oldHeight = this.height;
  1268.    this.height = height;
  1269.    this.redraw();
  1270. };
  1271. TableClass.prototype.redraw = function()
  1272. {
  1273.    this.borderClip.clear();
  1274.    var rows = this.rows;
  1275.    var rc = rows.length;
  1276.    var tmdims = this.maxCellDims;
  1277.    var x;
  1278.    var y;
  1279.    var r;
  1280.    var cc;
  1281.    var con;
  1282.    var cols;
  1283.    var rmdims;
  1284.    var cell;
  1285.    var cmax;
  1286.    var offset;
  1287.    var voffset;
  1288.    var cwid;
  1289.    var wprec;
  1290.    var newwid;
  1291.    var lastColMax = null;
  1292.    var cpad = this.cellPadding;
  1293.    var cspace = this.cellSpacing;
  1294.    var r = 0;
  1295.    while(r < rc)
  1296.    {
  1297.       cols = rows[r].cells;
  1298.       cc = cols.length;
  1299.       rmdims = rows[r - 1].maxCellDims;
  1300.       if(r == 0)
  1301.       {
  1302.          y = this.y;
  1303.       }
  1304.       else
  1305.       {
  1306.          y += rmdims.height + this.cellSpacing;
  1307.       }
  1308.       var c = 0;
  1309.       while(c < cc)
  1310.       {
  1311.          cell = cols[c];
  1312.          con = cell.getContent();
  1313.          cwid = this.colWidthMaxs[c];
  1314.          this._resizeTextfield(con,cwid);
  1315.          if(cell.halign == "right")
  1316.          {
  1317.             offset = cwid - con._width;
  1318.          }
  1319.          else if(cell.halign == "center")
  1320.          {
  1321.             offset = (cwid - con._width) / 2;
  1322.          }
  1323.          else
  1324.          {
  1325.             offset = 0;
  1326.          }
  1327.          if(cell.valign == "bottom")
  1328.          {
  1329.             voffset = rows[r].maxCellDims.height - con._height;
  1330.          }
  1331.          else if(cell.valign == "center")
  1332.          {
  1333.             voffset = (rows[r].maxCellDims.height - con._height) / 2;
  1334.          }
  1335.          else
  1336.          {
  1337.             voffset = 0;
  1338.          }
  1339.          if(c == 0)
  1340.          {
  1341.             x = this.x;
  1342.             lastColMax = cwid;
  1343.          }
  1344.          else
  1345.          {
  1346.             cmax = lastColMax;
  1347.             x += cmax + this.cellSpacing;
  1348.          }
  1349.          con._x = x + offset;
  1350.          con._y = y + voffset;
  1351.          if(this.borderSize > 0)
  1352.          {
  1353.             this.borderClip.lineStyle(this.borderSize,10066329,100);
  1354.             this.borderClip.drawRect(x,y,cwid,rows[r].maxCellDims.height);
  1355.          }
  1356.          lastColMax = cwid;
  1357.          c++;
  1358.       }
  1359.       r++;
  1360.    }
  1361.    this._recalcHeights();
  1362. };
  1363. TableClass.prototype._resizeTextfield = function(oIns, w, h)
  1364. {
  1365.    var txt = oIns.content;
  1366.    if(txt._width > w)
  1367.    {
  1368.       txt.wordWrap = true;
  1369.       txt._width = w;
  1370.       txt._width = Math.round(txt._width);
  1371.       trace("text width: " + txt.textWidth);
  1372.       if(this.reduceTextFields)
  1373.       {
  1374.          var h = txt._height;
  1375.          var w = txt._width;
  1376.          var old_w = 0;
  1377.          var txtWidth = txt.textWidth;
  1378.          var i = w;
  1379.          while(h == txt._height)
  1380.          {
  1381.             if(i <= 0)
  1382.             {
  1383.                break;
  1384.             }
  1385.             if(txt.textWidth < txtWidth)
  1386.             {
  1387.                break;
  1388.             }
  1389.             txt._width--;
  1390.             i--;
  1391.          }
  1392.          txt._width = txt._width + 1;
  1393.       }
  1394.    }
  1395.    oIns._width = txt._width;
  1396. };
  1397. TableClass.prototype._recalcHeights = function()
  1398. {
  1399.    var rows = this.rows;
  1400.    var rc = rows.length;
  1401.    var cc;
  1402.    var cols;
  1403.    var cell;
  1404.    this.height = 0;
  1405.    var r = 0;
  1406.    while(r < rc)
  1407.    {
  1408.       cols = rows[r].cells;
  1409.       cc = cols.length;
  1410.       var c = 0;
  1411.       while(c < cc)
  1412.       {
  1413.          cell = cols[c];
  1414.          rows[r]._checkMaxCellDims(cell);
  1415.          this.height += rows[r].maxCellDims.height;
  1416.          c++;
  1417.       }
  1418.       r++;
  1419.    }
  1420. };
  1421. TableClass.prototype._findLargestColumn = function()
  1422. {
  1423.    var largestId;
  1424.    var largest;
  1425.    var cmaxs = this.colWidthMaxs;
  1426.    var i = 0;
  1427.    while(i < cmaxs.length)
  1428.    {
  1429.       trace("finding largest: " + cmaxs[i]);
  1430.       if(largest < cmaxs[i])
  1431.       {
  1432.          largest = cmaxs[i];
  1433.          largestId = i;
  1434.       }
  1435.       i++;
  1436.    }
  1437.    return largestId;
  1438. };
  1439. TableClass.prototype._recalcDimensions = function(newWidth)
  1440. {
  1441.    var cw = this._getTableWidth();
  1442.    if(newWidth > cw)
  1443.    {
  1444.       return undefined;
  1445.    }
  1446.    trace("\n\n----");
  1447.    trace("TableClass.prototype._recalcDimensions:");
  1448.    trace("current width: " + cw + ", new width: " + newWidth);
  1449.    delete this.alteredColumns;
  1450.    this.alteredColumns = {};
  1451.    this._resizeTableR(cw,newWidth);
  1452.    var addback = newWidth - this._getTableWidth();
  1453.    var cmaxs = this.colWidthMaxs;
  1454.    var prc;
  1455.    var cmax = 0;
  1456.    var acc = 0;
  1457.    for(var nm in this.alteredColumns)
  1458.    {
  1459.       trace("ALTERED COLUMNS: " + nm);
  1460.       if(!isNaN(nm))
  1461.       {
  1462.          acc++;
  1463.       }
  1464.    }
  1465.    for(var colid in this.alteredColumns)
  1466.    {
  1467.       trace("Addback: " + colid + ", " + addback / acc);
  1468.       this.colWidthMaxs[parseInt(colid)] = this.colWidthMaxs[parseInt(colid)] + addback / acc;
  1469.    }
  1470.    if(addback / acc > 0)
  1471.    {
  1472.    }
  1473.    this.width = newWidth;
  1474. };
  1475. TableClass.prototype._resizeTableR = function(lastWidth, targetWidth)
  1476. {
  1477.    if(lastWidth <= targetWidth)
  1478.    {
  1479.       return undefined;
  1480.    }
  1481.    var largest;
  1482.    var largestId = 0;
  1483.    var cmaxs = this.colWidthMaxs;
  1484.    var i = 0;
  1485.    while(i < cmaxs.length)
  1486.    {
  1487.       trace("finding largest: " + cmaxs[i]);
  1488.       if(largest < cmaxs[i])
  1489.       {
  1490.          largest = cmaxs[i];
  1491.          largestId = i;
  1492.       }
  1493.       i++;
  1494.    }
  1495.    var prc = largest / lastWidth;
  1496.    trace("prc: " + prc);
  1497.    var ncw = largest * prc;
  1498.    cmaxs[largestId] = ncw;
  1499.    this.alteredColumns[largestId] = largestId;
  1500.    trace("\n\nAFTER:");
  1501.    trace("new largest: " + ncw);
  1502.    trace("lastWidth: " + lastWidth);
  1503.    trace("largest: " + largest);
  1504.    trace("targetWidth: " + targetWidth);
  1505.    trace("nextWidth: " + (lastWidth - (largest - ncw)));
  1506.    if(prc == 1)
  1507.    {
  1508.       cmax[largestId] = targetWidth;
  1509.       return undefined;
  1510.    }
  1511.    this._resizeTableR(lastWidth - (largest - ncw),targetWidth);
  1512. };
  1513. TableClass.prototype._getTableWidth = function()
  1514. {
  1515.    var width = 0;
  1516.    var lasti = this.colWidthMaxs.length - 1;
  1517.    var i = 0;
  1518.    while(i < this.colWidthMaxs.length)
  1519.    {
  1520.       width += this.colWidthMaxs[i];
  1521.       i++;
  1522.    }
  1523.    return width;
  1524. };
  1525. TableClass.prototype.init = function()
  1526. {
  1527.    this.redraw();
  1528. };
  1529. TableRow = function()
  1530. {
  1531.    this.cells = [];
  1532.    this.maxCellDims = {width:0,height:0};
  1533. };
  1534. TableRow.prototype.addCell = function(cell)
  1535. {
  1536.    this.cells.push(cell);
  1537.    var cc = cell.getContent();
  1538.    var cw = cc == null ? cell.width : cc._width;
  1539.    var ch = cc == null ? cell.height : cc._height;
  1540.    var mw = this.maxCellDims.width;
  1541.    var mh = this.maxCellDims.height;
  1542.    this.maxCellDims.width = cw <= mw ? mw : cw;
  1543.    this.maxCellDims.height = ch <= mh ? mh : ch;
  1544. };
  1545. TableRow.prototype._checkMaxCellDims = function(cell)
  1546. {
  1547.    var cc = cell.getContent();
  1548.    var cw = cc == null ? cell.width : cc._width;
  1549.    var ch = cc == null ? cell.height : cc._height;
  1550.    var mw = this.maxCellDims.width;
  1551.    var mh = this.maxCellDims.height;
  1552.    this.maxCellDims.width = cw <= mw ? mw : cw;
  1553.    this.maxCellDims.height = ch <= mh ? mh : ch;
  1554. };
  1555. TableCell = function(content)
  1556. {
  1557.    this.content = content;
  1558. };
  1559. TableCell.prototype.setContent = function(content)
  1560. {
  1561.    this.content = content;
  1562. };
  1563. TableCell.prototype.getContent = function()
  1564. {
  1565.    return this.content;
  1566. };
  1567. TableCell.prototype.setWidth = function(width, isPercent)
  1568. {
  1569.    this.widthIsPercent = isPercent != null ? true : false;
  1570.    this.width = width;
  1571. };
  1572. TableCell.prototype.setHeight = function(height, isPercent)
  1573. {
  1574.    this.heightIsPercent = isPercent != null ? true : false;
  1575.    this.height = height;
  1576. };
  1577. TableCell.prototype.setHAlign = function(halign)
  1578. {
  1579.    this.halign = halign;
  1580. };
  1581. TableCell.prototype.setVAlign = function(valign)
  1582. {
  1583.    this.valign = valign;
  1584. };
  1585. TextFormat.prototype.cGetTextExtent = function(s, bEmbedFonts, bAccurate)
  1586. {
  1587.    var __CGTE_mc = _root.createEmptyMovieClip("__PMSI_textExtBox__",4013145);
  1588.    __CGTE_mc._visible = false;
  1589.    __CGTE_mc.createTextField("content",1,0,0,0,0);
  1590.    var __CGTE_mc_txt = __CGTE_mc.content;
  1591.    __CGTE_mc_txt.autoSize = true;
  1592.    var __CGTE_marg_h = bAccurate != true ? 0 : __CGTE_mc_txt._height;
  1593.    var __CGTE_marg_v = bAccurate != true ? 0 : __CGTE_mc_txt._width;
  1594.    __CGTE_mc_txt.embedFonts = bEmbedFonts != null ? bEmbedFonts : true;
  1595.    __CGTE_mc_txt.type = "dynamic";
  1596.    __CGTE_mc_txt.selectable = false;
  1597.    __CGTE_mc_txt.text = s;
  1598.    __CGTE_mc_txt.setTextFormat(this);
  1599.    return {width:__CGTE_mc_txt._width - __CGTE_marg_h,height:__CGTE_mc_txt._height - __CGTE_marg_v};
  1600. };
  1601. TextField.prototype.findLines = function(ttf)
  1602. {
  1603.    var mc2 = _root.createEmptyMovieClip("__getLinesBox__",4013146);
  1604.    mc2._visible = false;
  1605.    ttf = ttf != null ? ttf : this.getTextFormat();
  1606.    var lh = ttf.cGetTextExtent("373_<3_4").height;
  1607.    var lines = [];
  1608.    mc2.createTextField("__fio__",1000,0,0,0,0);
  1609.    var f = mc2.__fio__;
  1610.    var als = this.text.split(" ");
  1611.    f._width = this._width;
  1612.    f.embedFonts = this.embedFonts;
  1613.    f.border = this.border;
  1614.    f.type = "dynamic";
  1615.    f.autoSize = true;
  1616.    f.selectable = false;
  1617.    f.wordWrap = true;
  1618.    f.multiline = true;
  1619.    var line = "";
  1620.    var i = 0;
  1621.    while(i < als.length)
  1622.    {
  1623.       f.text += " " + als[i];
  1624.       f.setTextFormat(ttf);
  1625.       if(f._height > lh && line != "")
  1626.       {
  1627.          lines.push(line.trim());
  1628.          f.text = "";
  1629.          line = "";
  1630.          i--;
  1631.       }
  1632.       line = f.text;
  1633.       f.setTextFormat(ttf);
  1634.       i++;
  1635.    }
  1636.    lines.push(f.text.trim());
  1637.    f.removeTextField();
  1638.    this.__lines = lines;
  1639.    return lines;
  1640. };
  1641. TextField.prototype.getLineAt = function(i)
  1642. {
  1643.    if(this.__lines == null)
  1644.    {
  1645.       this.findLines();
  1646.    }
  1647.    return this.__lines[i];
  1648. };
  1649. TextField.prototype.getLineCount = function()
  1650. {
  1651.    if(this.__lines == null)
  1652.    {
  1653.       this.findLines();
  1654.    }
  1655.    return this.__lines.length;
  1656. };
  1657. TextField.prototype.convertToLines = function()
  1658. {
  1659.    if(this.__lines == null)
  1660.    {
  1661.       this.findLines();
  1662.    }
  1663.    this.text = "";
  1664.    var i = 0;
  1665.    while(i < this.__lines.length - 1)
  1666.    {
  1667.       this.text += this.__lines[i] + "\n";
  1668.       i++;
  1669.    }
  1670.    this.text += this.__lines[this.__lines.length - 1];
  1671. };
  1672. TextField.prototype.getLines = function()
  1673. {
  1674.    if(this.__lines == null)
  1675.    {
  1676.       this.findLines();
  1677.    }
  1678.    return this.__lines;
  1679. };
  1680. stop();
  1681. var TXT_DEBUG_SHOW_BORDERS = false;
  1682. var testFile1 = "activities/data/C3.U3.S2.VO.A4.xml";
  1683. var testFile2 = "C1.U2.S3.VO.1.B2.xml";
  1684. var testFile3 = "C3.U3.S2.VO.A4.xml";
  1685. if(_parent)
  1686. {
  1687.    master = _parent;
  1688.    btnToggleLang._visible = false;
  1689.    if(PMSI.instructionLanguage == null)
  1690.    {
  1691.       PMSI.instructionLanguage = "English";
  1692.    }
  1693. }
  1694. else
  1695. {
  1696.    master = this;
  1697.    _global.PMSI = {};
  1698.    PMSI.instructionLanguage = "English";
  1699. }
  1700. if(master.layoutInfo == null)
  1701. {
  1702.    var layoutInfo = {};
  1703.    actBulletPosition = {};
  1704.    actBulletPosition.topx = actBullet._x;
  1705.    actBulletPosition.topy = actBullet._y;
  1706.    actBulletPosition.botx = 0;
  1707.    actBulletPosition.boty = 0;
  1708.    actAnswerPosition = {};
  1709.    actAnswerPosition.inix = 457;
  1710.    actAnswerPosition.iniy = 500;
  1711.    actAnswerPosition.secx = 694;
  1712.    actAnswerPosition.secy = 500;
  1713.    actAnswerPosition.pos1_x = 694;
  1714.    actAnswerPosition.pos1_y = 500;
  1715.    actAnswerPosition.pos2_x = 694;
  1716.    actAnswerPosition.pos2_y = 436;
  1717.    var layoutInfo = {};
  1718.    layoutInfo.actBulletTextColor = 16777215;
  1719.    layoutInfo.titleTextColor = 10053375;
  1720.    layoutInfo.answerRollOverColor = 16695085;
  1721.    layoutInfo.answerRollOutColor = layoutInfo.titleTextColor;
  1722.    layoutInfo.answerSelectColor = layoutInfo.titleTextColor;
  1723.    layoutInfo.questionTextColor = 2309272;
  1724.    layoutInfo.instTextColor = 2309272;
  1725.    layoutInfo.answerIncorrectColor = 16695085;
  1726.    layoutInfo.doAnswerFill = false;
  1727.    layoutInfo.rightSideBuffer = 10;
  1728.    layoutInfo.box = {};
  1729.    layoutInfo.box.x = 260;
  1730.    layoutInfo.box.y = 93;
  1731.    layoutInfo.box.views = [];
  1732.    layoutInfo.box.widthWithBox = 300;
  1733.    layoutInfo.box.heightWithBox = 300;
  1734.    layoutInfo.box.widthWithoutBox = 300;
  1735.    layoutInfo.box.heightWithoutBox = 300;
  1736.    layoutinfo.MAX_WIDTH = 520;
  1737.    layoutInfo.MAX_HEIGHT = 380;
  1738.    layoutInfo.questionIndent = 30;
  1739.    layoutInfo.selectionRadius = 6;
  1740.    layoutInfo.drawSelectionCircle = true;
  1741.    layoutInfo.lineSpacing = 5;
  1742.    layoutInfo.selectionBorderThickness = 1;
  1743.    layoutInfo.instTextFormat = new TextFormat();
  1744.    layoutInfo.instTextFormat.font = "Formata_Normal";
  1745.    layoutInfo.instTextFormat.size = 12;
  1746.    layoutInfo.instTextFormat.color = layoutInfo.instTextColor;
  1747.    layoutInfo.instTextFormatBold = new TextFormat();
  1748.    layoutInfo.instTextFormatBold.font = "Formata_Bold";
  1749.    layoutInfo.instTextFormatBold.size = 12;
  1750.    layoutInfo.instTextFormatBold.color = layoutInfo.instTextColor;
  1751.    layoutInfo.qTextFormat = new TextFormat();
  1752.    layoutInfo.qTextFormat.font = "Formata_Normal";
  1753.    layoutInfo.qTextFormat.size = 12;
  1754.    layoutInfo.qTextFormat.color = layoutInfo.questionTextColor;
  1755.    layoutInfo.qTextFormat.align = "right";
  1756.    layoutInfo.qTextFormat.leading = 2;
  1757.    layoutInfo.qTextFormatSA = new TextFormat();
  1758.    layoutInfo.qTextFormatSA.font = "Formata_Normal";
  1759.    layoutInfo.qTextFormatSA.size = 12;
  1760.    layoutInfo.qTextFormatSA.color = layoutInfo.questionTextColor;
  1761.    layoutInfo.qTextFormatSA.leading = 2;
  1762.    layoutInfo.qTextFormatMATCH = new TextFormat();
  1763.    layoutInfo.qTextFormatMATCH.font = "Formata_Normal";
  1764.    layoutInfo.qTextFormatMATCH.size = 12;
  1765.    layoutInfo.qTextFormatMATCH.color = layoutInfo.questionTextColor;
  1766.    layoutInfo.qTextFormatMATCH.leading = 2;
  1767.    layoutInfo.qTextFormatBANK = new TextFormat();
  1768.    layoutInfo.qTextFormatBANK.font = "Formata_Normal";
  1769.    layoutInfo.qTextFormatBANK.size = 12;
  1770.    layoutInfo.qTextFormatBANK.color = layoutInfo.questionTextColor;
  1771.    layoutInfo.qTextFormatBANK.leading = 2;
  1772.    layoutInfo.qTextFormatMULTI = new TextFormat();
  1773.    layoutInfo.qTextFormatMULTI.font = "Formata_Normal";
  1774.    layoutInfo.qTextFormatMULTI.size = 12;
  1775.    layoutInfo.qTextFormatMULTI.color = layoutInfo.questionTextColor;
  1776.    layoutInfo.qTextFormatMULTI.leading = 2;
  1777.    layoutInfo.answerTextFormat1 = new TextFormat();
  1778.    layoutInfo.answerTextFormat1.font = "Formata_Normal";
  1779.    layoutInfo.answerTextFormat1.size = 12;
  1780.    layoutInfo.answerTextFormat1.color = layoutInfo.answerRollOutColor;
  1781.    layoutInfo.answerTextFormat2 = new TextFormat();
  1782.    layoutInfo.answerTextFormat2.font = "Formata_Normal";
  1783.    layoutInfo.answerTextFormat2.size = 12;
  1784.    layoutInfo.answerTextFormat2.color = layoutInfo.answerRollOutColor;
  1785.    layoutInfo.titleTextFormat = new TextFormat();
  1786.    layoutInfo.titleTextFormat.font = "TriplexCondSerifBlack";
  1787.    layoutInfo.titleTextFormat.size = 24;
  1788.    layoutInfo.titleTextFormat.color = layoutInfo.titleTextColor;
  1789.    layoutInfo.actBulletTextFormat = new TextFormat();
  1790.    layoutInfo.actBulletTextFormat.font = "Formata_Bold";
  1791.    layoutInfo.actBulletTextFormat.bold = true;
  1792.    layoutInfo.actBulletTextFormat.size = 14;
  1793.    layoutInfo.actBulletTextFormat.color = layoutInfo.actBulletTextColor;
  1794.    layoutInfo.actFeedbackColor = 10053375;
  1795.    layoutInfo.actCorrectFeedbackColor = 16695085;
  1796.    layoutInfo.actFeedbackTextFormat = new TextFormat();
  1797.    layoutInfo.actFeedbackTextFormat.font = "Formata_Bold";
  1798.    layoutInfo.actFeedbackTextFormat.size = 15;
  1799.    layoutInfo.actFeedbackTextFormat.color = layoutInfo.actFeedbackColor;
  1800.    layoutInfo.actCorrectFeedbackTextFormat = new TextFormat();
  1801.    layoutInfo.actCorrectFeedbackTextFormat.font = "Formata_Bold";
  1802.    layoutInfo.actCorrectFeedbackTextFormat.size = 15;
  1803.    layoutInfo.actCorrectFeedbackTextFormat.color = layoutInfo.actCorrectFeedbackColor;
  1804.    layoutInfo.matchingCircleColor = 16695085;
  1805.    layoutInfo.matchingCircleRadius = 4;
  1806.    layoutInfo.matchingCircleSpacer = 50;
  1807.    layoutInfo.matchingCircleLineThickness = 2;
  1808.    layoutInfo.matchingCircleVertOffset = 4;
  1809. }
  1810. else
  1811. {
  1812.    layoutInfo = master.layoutInfo;
  1813. }
  1814. layoutInfo.rightSideBuffer = 60;
  1815. var ai = new ActivityInfo();
  1816. ai._parent = this;
  1817. ai.onLoad = function(success)
  1818. {
  1819.    trace("id:   " + this.getIdString());
  1820.    trace("type: " + this.type);
  1821.    var i = 0;
  1822.    while(i < this.questions.question.length)
  1823.    {
  1824.       trace(i + 1 + ". " + this.questions.question[i].questionText);
  1825.       i++;
  1826.    }
  1827.    this._parent.render();
  1828.    trace("Time: " + (getTimer() - t) / 1000);
  1829. };
  1830. if(_parent == null)
  1831. {
  1832.    loadActivity(testFile1);
  1833. }
  1834. answer.onRelease = function()
  1835. {
  1836.    checkAnswers();
  1837. };
  1838. answer.onRollOver = function()
  1839. {
  1840.    this.gotoAndStop("rollOver");
  1841. };
  1842. answer.onRollOut = function()
  1843. {
  1844.    this.gotoAndStop("rollOut");
  1845. };
  1846. TAGS = {};
  1847. TAGS.BLANK_OPEN = "[:blank:]";
  1848. TAGS.BLANK_CLOSE = "[:/blank:]";
  1849.